import axios from "axios";
import {message} from "antd";

const authRequest = axios.create({
    baseURL:"/auth"
})
// 请求拦截
authRequest.interceptors.request.use((config:any)=>{
    // 判断是否拥有token
    if(localStorage.getItem("token"))
        config.headers.token = localStorage.getItem("token");
    return config;
})
authRequest.interceptors.response.use(res=>{
    if(res.data.code === 200){
        // message.success(res.data.message);
        return res.data
    }
    message.error(res.data.message);
    return new Promise(()=>{});

});
export default authRequest;